package cn.com.git.example.common;

import cn.com.git.example.common.base.BaseResult;
import cn.com.git.example.common.base.BaseResultConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

@Data
@ApiModel
public class ResultMsg<D> extends BaseResult {
    @ApiModelProperty("返回参数")
    private D data;

    public ResultMsg(BaseResultConstant baseResultConstant) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), baseResultConstant.getMessage());
    }

    public ResultMsg(BaseResultConstant baseResultConstant, String message) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), message);
    }

    public ResultMsg(BaseResultConstant baseResultConstant, String message, D data) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), StringUtils.isEmpty(message) ? baseResultConstant.getMessage() : message);
        this.data = data;
    }

    public ResultMsg(int code, boolean success, String message,D data) {
        super(code, success, message);
        this.data = data;
    }
}
